//
//  ViewController.m
//  TitleContentExample
//
//  Created by 唐可雄 on 2019/7/13.
//  Copyright © 2019 swustyc. All rights reserved.
//

#import "ViewController.h"

#import <TitleContent/TitleContent.h>

@interface ViewController ()<YCTitleContentViewControllerDataSource, YCTitleContentViewControllerDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    YCTitleContentViewController *c = [[YCTitleContentViewController alloc] init];
    c.config = [[YCTitleContentConfig alloc] init];
    c.config.collectionViewCellSpace = 15;
    c.config.titleViewPos = YCTitleViewPosNavi;
    c.config.titleViewStyle = YCTitleViewStyleCollection;
    c.config.lineViewTransitionType = YCLineViewTransitionTypePull;
    c.config.lineViewShape = YCLineViewShapeRoundRect;
    c.config.collectionViewEdgeInsets = UIEdgeInsetsMake(4, 8, 4, 8);
    c.config.titleViewHeight = 40;
    c.config.textVerAlignment = YCTextVerAlignmentCenter;
    c.config.textColorSelected = [UIColor colorWithRed:10/255.f green:190/255.f blue:6/255.f alpha:1];
    c.config.textFontSelected = [UIFont systemFontOfSize:18];
    c.config.textColorUnselected = [UIColor colorWithRed:51/255.f green:51/255.f blue:51/255.f alpha:1];
    c.config.textFontUnselected = [UIFont systemFontOfSize:18];
    c.config.lineViewWidth = 22;
    c.config.lineViewHeight = 2;
    c.config.lineViewAlignment = YCLineViewAlignmentBottom;
    c.config.lineViewBackgroundColor = [UIColor colorWithRed:10/255.f green:190/255.f blue:6/255.f alpha:1];
    c.config.separatorViewColor = [UIColor colorWithRed:238/255.f green:238/255.f blue:238/255.f alpha:1];
    c.dataSource = self;
    c.delegate = self;
    [c displayInParentViewController:self];
}

- (NSUInteger)numberOfTitlesInTitleContentViewController:(YCTitleContentViewController *)titleContentVC {
    return 2;
}

- (NSString *)titleContentViewController:(YCTitleContentViewController *)titleContentVC textTitleForIndex:(NSUInteger)index {
    return @"汉字";
}

- (UIViewController *)titleContentViewController:(YCTitleContentViewController *)titleContentVC contentViewControllerForIndex:(NSInteger)index {
    if (index == 0) {
        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"vcDemo"];
        vc.view.backgroundColor = [UIColor blueColor];
        return vc;
    } else {
        UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"vcTest"];
        vc.view.backgroundColor = [UIColor redColor];
        return vc;
    }
}

- (void)titleContentViewController:(YCTitleContentViewController *)titleContentVC didSelectAtIndex:(NSInteger)index {
    
}


@end
